
import queue
import sys
import _thread
import time
import random
import os

from typing import MappingView
from PyQt5 import QtCore, QtGui, QtWidgets, Qt
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication


from controller.counter import CounterMainWindow as b_ui
from ui.ui2 import Ui_MainWindow as a_ui

from libs.keyboard import Keyboard
from libs.counter import ImageCounter
from libs.qrcode import Qrcode
from libs.ioctrl import IoCtrl

from bases import globalvar
from bases.player import SoundPlayer

class AUi(QtWidgets.QMainWindow, a_ui):
    def __init__(self):
        super(AUi, self).__init__()
        self.setupUi(self)
        self.bt2.clicked.connect(self.click_pushButton_2)  # 点击 pushButton_2 触发
    
    def click_pushButton_2(self):  # 点击 pushButton_2 触发
        self.lineEdit.clear()
        
    def keyPressEvent(self, event:QtGui.QKeyEvent):
        print("按下：" + str(event.key()))
        # keyStr = event.text()
        # print(keyStr)
        # 举例
        if(event.key() == 16777220):
            mainWindow.show()
            print('测试：Enter')
        if(event.key() == Qt.Key_Escape):
            self.lineEdit.clear()
            print('测试：Esc')
            

if __name__== '__main__':
    app = QtWidgets.QApplication(sys.argv)
    a = AUi()
    a.show()
    mainWindow = b_ui()
    #mainWindow.showFullScreen()
    #mainWindow.showMaximized()
    a.bt1.clicked.connect(
        lambda:{mainWindow.showFullScreen()}
        )
    #https://www.cnblogs.com/yuanjunyan/p/15044381.html
    # 各种初始化
    Keyboard.gpioinit()
    globalvar._init()
    SoundPlayer.init()    
    sys.exit(app.exec_())